﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<nelech.Models.DBModel.Zimer>" %>

<%@ Import Namespace="nelech.Views.Shared.Code" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    צור צימר חדש
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">

    <script src="../../Scripts/tinymce/jscripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>

    <script type="text/javascript">


       
        
        tinyMCE.init({ theme: "advanced",
            mode: "exact",
            elements: "description",
            plugins: "",
            theme_advanced_buttons1_add_before: "forecolor,backcolor,copy,paste,fontselect", 
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_more_colors: true,
            theme_advanced_styles: "NormalBold 1=firstBold;Normal 2=first;Normal 3=second;", 
            content_css: "/Content/tinymce.css"
        });


      
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% var db = new nelech.Models.DBModel.nelechDBEntities(); %>
    <h2>
        צור צימר חדש</h2>
    <% using (Html.BeginForm(this.Model == null ? "CreateZimer" : "EditZimer", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" }))
       {
    %>
    <fieldset>
        <legend>שדות</legend>
        <%
            if (Model != null)
            {
        %>
        <input type="hidden" name="id" value="<%= Model.id %>" />
        <input type="hidden" name="publish" value="1" />
        <%
            }
        %>
        <p>
            <label for="name">
                שם:</label>
            <%= Html.TextBox("name", this.Model == null || this.Model.name == null ? string.Empty : this.Model.name.ToString())%>
        </p>
        <p>
            <%= Html.LabelFor(model => model.lon)%>
            <%= Html.TextBox("lon", this.Model == null || this.Model.lon == null ? string.Empty : this.Model.lon.ToString())%>
            <%= Html.ValidationMessageFor(model => model.lon)%>
        </p>
        <p>
            <%= Html.LabelFor(model => model.lat)%>
            <%= Html.TextBox("lat", this.Model == null || this.Model.lat == null ? string.Empty : this.Model.lat.ToString())%>
        </p>
        <p>
            <label for="_regeon">
                אזור:</label>
            <%= Html.DropDownList("_regeon", Utils.CreateRegeonListItems(this.Model == null ? null : new Nullable<int>(this.Model.Regeon1.id)))%>
        </p>
        <p>
            <label for="description">
                פרטים:</label>
            <%= Html.TextArea("description", new { rows = "15", cols = "80", id = "description" })%>
        </p>
        <p>
            <label for="size">
                סוג:</label>
            <%
                foreach (var size in db.Size)
                {
                    Response.Write(Html.CheckBox("size" + size.id.ToString(), Model != null && Model.Size != null && Model.Size.Contains(size, new SizeComparer())));
                    Response.Write(size.text);
                }
            %>
            </p>
        <p>
            <label for="phone">
                טלפון להזמנות:</label>
           <%= Html.TextBox("phone", this.Model == null || this.Model.phone == null ? string.Empty : this.Model.phone.ToString())%>
        </p>
         <p>
            <label for="address">
                כתובת:</label>
           <%= Html.TextBox("address", this.Model == null || this.Model.address == null ? string.Empty : this.Model.address.ToString())%>
        </p>
         <p>
           <label for="chackted">
                    נבדק לאחרונה:</label>
                <%= Html.TextBox("chackted", this.Model == null || this.Model.chackted == null ? string.Empty : this.Model.chackted.ToString())%>
     
        </p>
         <p>
            <label for="address">
                קישור:</label>
           <%= Html.TextBox("link", this.Model == null || this.Model.link == null ? string.Empty : this.Model.link.ToString())%>
        </p>
            <%
                IEnumerator<nelech.Models.DBModel.Image> enm = null;
                if (Model != null)
                {
                    enm = Model.Image.GetEnumerator();
                }
                for (int i = 1; i < 11; i++)
                {
            %>
            <p>
                <%
                    if (enm != null && enm.MoveNext())
                    {
                %>
                <label for="imagePath<%= i %>">
                    <%= enm.Current.text%>:
                </label>
                <br />
                <img class="thumbs" src="<%= enm.Current.path %>" />
                <a href="/Admin/RemoveImage/<%= enm.Current.id %>">מחק</a>
                <%
                    }
        else
        {
                %>
                <label for="imagePath<%= i %>">
                    תמונה:
                </label>
                <input type="file" name="imagePath<%= i %>" size="40" /><br />
                <label for="imageLabel<%= i %>">
                    כיתוב:</label>
                <input type="text" name="imageLabel<%= i %>" size="40" />
                <%
                    }
                %>
            </p>
            <%
                }
            %>
        </p>
        <p>
            <input type="submit" value="שמור" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("חזרה לרשימה", "ListZimer") %>
    </div>



   

</asp:Content>
